#include <iostream>
 
class calculation   // 抽象类：具有纯虚函数的类   // 接口类 
{  // 抽象类不能构建对象
public:
   virtual int calculate(int a,int b) = 0; // 纯虚函数
};

// 继承自抽象类的类仍然是抽象类，只有重写了纯虚函数才可以实例化
class Add:public calculation
{
public:
    virtual int calculate(int a,int b)
    {
        return a + b;
    }
};

class Minus:public calculation
{
public:
    virtual int calculate(int a,int b)
    {
        return a - b;
    }
};

class Mutiply:public calculation
{
public:
    virtual int calculate(int a,int b)
    {
        return a * b;
    }
};

class Devide : public calculation
{
public:
    virtual int calculate(int a,int b)
    {
        return a / b;
    }
};

void calculation(calculation *c,int a,int b)
{
    std::cout<< c->calculate(a,b)<<std::endl;
}

int main()
{
    // calculation c;  // 抽象类不能构建对象
    
    calculation(new Mutiply,3,2);
    return 0;
}
